package cn.edu.hitsz.backup;

import java.io.FileWriter;
import java.io.IOException;

import cn.edu.hitsz.conf.LoadConfiguration;

/**
 * Delay write log
 * 
 * @author mingchen
 * @date 2015年8月19日
 */
public class UndealedDataPro {

	private static FileWriter writer = null;

	/**
	 * 
	 * Constructor function of Class
	 */
	private UndealedDataPro() {
		try {
			writer = new FileWriter(LoadConfiguration.getStringValueByKey("")
					+ "/" + "delayWrite.file", true);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	/**
	 * write content to the tail of the file
	 * @param content
	 * @return
	 * boolean
	 * 2015年8月19日
	 */
	public static synchronized boolean appendTo(String content) {
		if (writer == null) {
			new UndealedDataPro();
		}
		boolean success = false;
		try {
			writer.write(content);
			success = true;
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				writer.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return success;
	}
}
